package com.song.demo.controller;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author TonySong
 * @date 2024/4/28 0028
 * @time 10:24
 */
@RestController
@RequestMapping("service-test")
@ConfigurationProperties(prefix = "my")
@Data
public class HelloController {

    //读取name
    @Value("${student.name}")
    private String username;
    //读取hobby（和）

    private List<String> list =new ArrayList<>();

    public String getUsername() {
        return username;
    }


    @GetMapping("/hi")
    public String hello() {
        System.out.println("用户姓名"+username);
        System.out.println("爱好是：");
        this.list.forEach(System.out::println);
        return "hello";
    }

    @GetMapping("/h1")
    public String hello1() {
        return "你好";
    }
}
